package protectora;

import java.util.Iterator;
import java.util.List;

public class Busqueda {
	
	//Atributos
	
	private String TipoAnimal;
	
	//Constructores
	
	public Busqueda (){
		
	}
	
	
	//Metodos
	
	public static Animales buscarAnimalesEstricto(Animales anm, Protectora pr){
		Animales resul = null;
		if (anm instanceof Perro)
			resul =buscarPerro (anm, pr);
			
			
		if (anm instanceof Gato)
			resul = buscarGato (anm, pr);
		
		return resul;	
	}

	private static Animales buscarGato(Animales anm, Protectora pr) {
		Gato resul = null;
		Gato anm1 = (Gato)anm;
		List animales = pr.getAnimales();
		if (animales.contains(anm1)){
			Iterator itl = animales.iterator();
			while (itl.hasNext() && resul == null){
				Object e  = itl.next();
				if (e instanceof Gato){
					Gato aux = (Gato)e;
					if (aux.descripcionGato(anm1)){
						resul = aux;
					}
				}
			}
		}
		return null;
	}


	public static Perro buscarPerro(Animales anm, Protectora pr){
		Perro resul = null;
		Perro anm1 = (Perro)anm;
		List animales = pr.getAnimales();
		if(animales.contains(anm1)){
			Iterator itl = animales.iterator();
			while(itl.hasNext() && resul== null){
				Object e = itl.next();
				if(e instanceof Perro){
					Perro aux = (Perro)e;
					if (aux.descripcionPerro(anm1)){
						resul = aux;
					}
				}
			}
		}
		
		return resul;
	}
	
	public CasaDeAcogida BuscaCasaAcogida(String Nombre, String direccion){
		return null;
		
		
	}
	
	public Protectora BuscaProtectora(){
		return null;
		
		
	}
	
	public Persona BuscaVoluntario(){
		return null;
		
		
	}
}

